#Define the user Language: english or chinese
CC= g++
CFLAGS=  -Wstrict-prototypes -Wall -Wunused   -DOS_LINUX -DNER_PERSON -DPOS_TAGGER

#LDFLAGS= -ldl
LDFLAGS=

all:GSearch  clean

GSearch:GSearch.o ParseCommand.o ScanDisk.o BuildIndex.o SearchServer.o DisplayResult.o ContentSearch.o
	g++ $(CFLAGS) GSearch.o ParseCommand.o  ScanDisk.o BuildIndex.o SearchServer.o DisplayResult.o ContentSearch.o -pthread -o gsearch

GSearch.o: GSearch.cpp 
	g++ $(CFLAGS) -c GSearch.cpp 

ParseCommand.o:ParseCommand.cpp
	g++ $(CFLAGS) -c ParseCommand.cpp

ScanDisk.o: ScanDisk.cpp 
	g++ $(CFLAGS) -c ScanDisk.cpp 

BuildIndex.o:BuildIndex.cpp
	g++ $(CFLAGS) -c BuildIndex.cpp 

SearchServer.o:SearchServer.cpp
	g++ $(CFLAGS) -c SearchServer.cpp 

DisplayResult.o:DisplayResult.cpp
	g++ $(CFLAGS) -c DisplayResult.cpp

ContentSearch.o:ContentSearch.cpp
	g++ $(CFLAGS) -c ContentSearch.cpp
clean:
	rm *.o

install:gsearch
	mkdir /usr/local/gsearch
	chmod 777 /usr/local/gsearch
	cp ./gsearch /usr/bin/
	cp ./FileType.txt /usr/local/gsearch/
	cp ./ScanDirectories.txt /usr/local/gsearch/
	cp ./Translation.dat /usr/local/gsearch/
	cp ./gsearch_crontab /usr/local/gsearch/
	crontab /usr/local/gsearch/gsearch_crontab
	
uninstall:
	rm -f /usr/bin/gsearch
	rm -f /usr/local/gsearch/*
	rmdir /usr/local/gsearch

reinstall:
	cp ./gsearch /usr/bin/
	cp ./FileType.txt /usr/local/gsearch/
	cp ./ScanDirectories.txt /usr/local/gsearch/
	cp ./Translation.dat /usr/local/gsearch/
